<?php require_once 'core/app.php';
APP::load_helper('basic');

if (!isset($_POST['username']) || !isset($_POST['password']) 
	|| empty($_POST['username']) || empty($_POST['password'])) {
	return output_failed('empty_username_or_password');
}

$username = $_POST['username'];
$password = $_POST['password'];

$admin = APP::load_config('admin');
if ($username != $admin['username'] || $password != $admin['password']) {
	return output_failed('wrong_username_or_password');
}

session_start();
$_SESSION['admin'] = $username;
return output_success();